/*
 * Payee.java
 *
 *  
 */
package org.msb.finance.data;

/**
 * The {@code Payee} class represents a payee defined in the {@link Cabinet} object. A payee is the party other than the
 * one represented by this {@code Cabinet} object.
 * 
 * @author Marc Boudreau
 * 
 */
public class Payee implements Comparable<Payee> {

	/*
	 * The name of this payee. The name uniquely identifies the payee.
	 */
	private String name;

	/*
	 * 
	 */
	private String accountNum;

	/*
	 * 
	 */
	private String address;

	/*
	 * 
	 */
	private String phone;

	/*
	 * 
	 */
	private String website;

	/*
	 * 
	 */
	private String email;

	/*
	 * Constructor mandated by JDO specification.
	 */
	@SuppressWarnings("unused")
	private Payee() {
		this(null);
	}

	/**
	 * 
	 * @param name
	 */
	public Payee(String name) {
		this.name = name;
	}

	/**
	 * Returns the name of this {@code Payee} object. The name is never {@code null}.
	 * 
	 * @return A {@link String} object containing the name of this payee.
	 */
	public String getName() {
		return name;
	}

	/*
	 * The name of a payee is set in the constructor or by the renamePayee method of the Cabinet class. This method is
	 * provided with package access only to enable the renamePayee method to change the name field.
	 */
	void setName(String newName) {
		name = newName;
	}

	/**
	 * Returns the account number with this {@code Payee} object. This value is kept for reference purposes only.
	 * 
	 * @return A {@link String} object containing the account number.
	 */
	public String getAccountNum() {
		return accountNum;
	}

	/**
	 * 
	 * @param accountNum
	 */
	public void setAccountNum(String accountNum) {
		this.accountNum = accountNum;
	}

	/**
	 * 
	 * @return
	 */
	public String getAddress() {
		return address;
	}

	/**
	 * 
	 * @param address
	 */
	public void setAddress(String address) {
		this.address = address;
	}

	/**
	 * 
	 * @return
	 */
	public String getPhone() {
		return phone;
	}

	/**
	 * 
	 * @param phone
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
	 * 
	 * @return
	 */
	public String getWebsite() {
		return website;
	}

	/**
	 * 
	 * @param website
	 */
	public void setWebsite(String website) {
		this.website = website;
	}

	/**
	 * 
	 * @return
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * 
	 * 
	 * @param email
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	public int compareTo(Payee payee) {
		if (this == payee) {
			return 0;
		}

		return name.compareTo(payee.name);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		} else if (null == obj) {
			return false;
		} else if (this.getClass() == obj.getClass()) {
			return name.equals(((Payee) obj).name);
		}

		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return name.hashCode() ^ Payee.class.hashCode();
	}
}
